# -- coding:UTF-8 --

import os
import sys
import json

# 项目地址
Path_Project = sys.path[0]
Path_Project=Path_Project.replace('\commands' , '')

def removeTTF(filePath):
    ttfMetaList = [
        "7710c758-f74b-4a6e-a891-7405c1a295b8",
        "52a593f1-8937-4735-980a-25fbe5845fd1",
        "5b4c5795-182a-453c-9617-9285c5dea500",
        "fb0ac5b7-b604-45ab-8bb8-48488748c5ab",
    ]

    with open(filePath, 'r', encoding="utf-8") as load_f:
        load_f = json.load(load_f)

    flag = False
    for value in load_f:
        if "__type__" in value:
            if value["__type__"] == "cc.Label":
                if value["_N$file"] != None:
                    if "__uuid__" in value["_N$file"]:
                        if value["_N$file"]["__uuid__"] in ttfMetaList:
                            print(value["_N$file"]["__uuid__"])
                            flag = True
                            value["_N$file"] = None
            
            if value["__type__"] == "cc.RichText":
                if value["_N$font"] != None:
                    if "__uuid__" in value["_N$font"]:
                        if value["_N$font"]["__uuid__"] in ttfMetaList:
                            print(value["_N$font"]["__uuid__"])
                            flag = True
                            value["_N$font"] = None
    if flag:
        with open(filePath, 'w') as dump_f:
            json.dump(load_f, dump_f, indent=2)
                    

def findPrefab(folderPath, extend_name):
    for item in os.listdir(folderPath):
        if os.path.isdir(os.path.join(folderPath, item)):
            subFolderPath = os.path.join(folderPath, item)
            findPrefab(subFolderPath, extend_name)
        else:
            filePath = os.path.join(folderPath, item)
            if (os.path.isfile(filePath)):
                if item.split('.')[-1] in extend_name:
                    removeTTF(filePath)


# ---------------------------------main----------------------------#
findPrefab(Path_Project + "\\assets", ["prefab", "fire"])
os.system('pause')
